// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
  env:"cloud1-3g1yerk2e342b1a8",
})

// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  const db=cloud.database();

  return await db.collection("UserInfos").where({
    openid:wxContext.OPENID
  }).get().then(res=>{
    if(res.data.length){
      return {data:res.data[0],code:200}
    }else{
      return {code:400}
    }
  })
  
}